import java.util.HashMap;
import java.util.Map;

/**
 * 交互客户端
 *
 * @author fy
 * @date 2022/8/23 22:02
 */
public class Client {

    public static void main(String[] args) {
        Client client = new Client();

        // 题目1
        Map<String, Double> goods1 = new HashMap<>(2);
        goods1.put("苹果", 3d);
        goods1.put("草莓", 10d);
        double totalPrice1 = client.buyFruit(1, goods1);
        assert totalPrice1 == 154.0d;

        // 题目2
        Map<String, Double> goods2 = new HashMap<>(3);
        goods2.put("苹果", 3d);
        goods2.put("草莓", 10d);
        goods2.put("芒果", 5d);
        double totalPrice2 = client.buyFruit(1, goods2);
        assert totalPrice2 == 254.0d;

        // 题目3
        Map<String, Double> goods3 = new HashMap<>(3);
        goods3.put("苹果", 3d);
        goods3.put("草莓", 10d);
        goods3.put("芒果", 5d);
        double totalPrice3 = client.buyFruit(1, goods3);
        assert totalPrice3 == 249.2d;

        // 题目4
        Map<String, Double> goods4 = new HashMap<>(3);
        goods4.put("苹果", 3d);
        goods4.put("草莓", 10d);
        goods4.put("芒果", 5d);
        double totalPrice4 = client.buyFruit(1, goods4);
        assert totalPrice4 == 239.2d;
    }

    /**
     * 测试不同场景
     *
     * @param caseType case值
     * @param goods    购买的商品
     * @return 总价
     */
    private double buyFruit(int caseType, Map<String, Double> goods) {
        SuperMarket superMarket = new SuperMarket(caseType);
        return superMarket.calcPrice(goods);
    }

}
